package com.loongtech.bi.manager.game;

import com.loongtech.bi.entity.game.EntityMallStatistics10Level;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
/*
 * 10等级 商城统计
 */
@Service
public class MallStatistics10LevelManager extends ManagerQueryCacheBase<EntityMallStatistics10Level> {
	private static final long serialVersionUID = 1L;
	
	//根据区服查询
	public List<Object[]> getMallStatistics10LevelByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype) {
		return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1  and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
	}
	
	//根据物品id和等级查询
	public List<Object[]> getMallStatistics10LevelByAllKindByParamAndRolelevel(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype,Long param,Integer rolelevel) {
		return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1 and param = "+param+" and rolelevel = "+rolelevel+"  and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
	}
	
	//根据物品id查询
	public List<Object[]> getMallStatistics10LevelByAllKindByParam(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype,Long param) {
		return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1 and param = "+param+"  and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
	}
	
	//根据等级查询
	public List<Object[]> getMallStatistics10LevelByAllKindByRolelevel(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype,Integer rolelevel) {
		return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1 and rolelevel = "+rolelevel+" and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
	}
	
	//根据日期范围查询等级
	public List<Object[]> getMallStatistics10LevelByDateEnd(Date dateStart,Date dateEnd) {
		return findByQuery("select rolelevel from EntityMallStatistics10Level  where 1=1 and day>=:dayStart and day<=:dayEnd group by rolelevel order by rolelevel asc","dayStart", dateStart, "dayEnd", dateEnd);
	}


    //根据区服查询
    public List<Object[]> getMallStatistics10LevelByAllKind(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype, String reason) {
        return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1 and reason=" + reason + " and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
    }

    //根据物品id和等级查询
    public List<Object[]> getMallStatistics10LevelByAllKindByParamAndRolelevel(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype,Long param,Integer rolelevel, String reason) {
        return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1 and reason=" + reason + " and param = "+param+" and rolelevel = "+rolelevel+"  and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
    }

    //根据物品id查询
    public List<Object[]> getMallStatistics10LevelByAllKindByParam(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype,Long param, String reason) {
        return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1 and reason=" + reason + " and param = "+param+"  and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
    }

    //根据等级查询
    public List<Object[]> getMallStatistics10LevelByAllKindByRolelevel(Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer,String currencytype,Integer rolelevel, String reason) {
        return findByQuery("select date_format(day,'%Y-%m-%d'),rolelevel,param,sumchangenum,times,rolenum,currencytype,reason from EntityMallStatistics10Level  where 1=1 and reason=" + reason + " and rolelevel = "+rolelevel+" and currencytype in "+ currencytype +" and day>=:dayStart and day<=:dayEnd and platformid = '"+queryPlatform+"' and serverid = '"+queryServer+"' and channelid = '"+queryChannel+"' order by day desc,rolelevel asc", "dayStart", dateStart, "dayEnd", dateEnd);
    }

    //根据日期范围查询等级
    public List<Object[]> getMallStatistics10LevelByDateEnd(Date dateStart,Date dateEnd, String reason) {
        return findByQuery("select rolelevel from EntityMallStatistics10Level  where 1=1 and reason=" + reason + " and day>=:dayStart and day<=:dayEnd group by rolelevel order by rolelevel asc","dayStart", dateStart, "dayEnd", dateEnd);
    }
}
